# $Id: PKGBUILD 183595 2013-04-24 06:52:38Z bisson $
# Contributor: Dale Blount <dale@archlinux.org>
# Contributor: Gregor Ibic <gregor.ibic@intelicom.si>
# Maintainer: Gaetan Bisson <bisson@archlinux.org>

pkgname=clamav
pkgver=0.97.8
pkgrel=1
pkgdesc='Anti-virus toolkit for Unix'
url='http://www.clamav.net/'
license=('GPL')
options=('!libtool')
arch=('i686' 'x86_64')
depends=('bzip2' 'libltdl')
backup=('etc/clamav/clamd.conf' 'etc/clamav/freshclam.conf' 'etc/conf.d/clamav')
source=("http://downloads.sourceforge.net/project/${pkgname}/${pkgname}/${pkgver}/${pkgname}-${pkgver}.tar.gz"
        'rc.d'
        'conf.d'
        'service'
        'service.fresh'
        'logrotate'
        'tmpfiles.d'
        'config.patch')
sha1sums=('078c0ac2b4e69d27eecd7544a8361abcd859e73c'
          'c9d508c1e5972f0f849d8694c1872455fa9e74de'
          'cb116cdab49a810381a515cbcfb6a6c148547f07'
          'df522b0488f3901e491f148c9300f6bae348c605'
          'cda9a087e5593992150cb456e34c5f6f589aca82'
          '7cace58743a36dae3e63e5e0c6cc73ea5ef9a6ee'
          'a224ea9b4d0f4f196827347d54bed51e11c197ea'
          '1c8ef193919b041135115170acd6313f008de808')

install=install

prepare() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	patch -p1 -i ../config.patch
}

build() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	./configure \
		--prefix=/usr \
		--sysconfdir=/etc/clamav \
		--with-dbdir=/var/lib/clamav \
		--disable-clamav \

	make
}

package() {
	cd "${srcdir}/${pkgname}-${pkgver}"
	make DESTDIR="${pkgdir}" install

	# Make sure conf files get installed, because make install
	# doesn't do that if clamav is already installed upon building.
	install -Dm644 etc/clamd.conf "${pkgdir}"/etc/clamav/clamd.conf
	install -Dm644 etc/freshclam.conf "${pkgdir}"/etc/clamav/freshclam.conf

	install -Dm644 ../service.fresh "${pkgdir}"/usr/lib/systemd/system/freshclamd.service
	install -Dm644 ../service "${pkgdir}"/usr/lib/systemd/system/clamd.service
	install -Dm644 ../tmpfiles.d "${pkgdir}"/usr/lib/tmpfiles.d/clamav.conf
	install -Dm644 ../logrotate "${pkgdir}"/etc/logrotate.d/clamav
	install -Dm644 ../conf.d "${pkgdir}"/etc/conf.d/clamav
	install -Dm755 ../rc.d "${pkgdir}"/etc/rc.d/clamav

	install -d -o 64 -g 64 "${pkgdir}"/run/clamav
	install -d -o 64 -g 64 "${pkgdir}"/var/log/clamav
	install -d -o 64 -g 64 "${pkgdir}"/var/lib/clamav
}
